<?php
namespace Ccc\Gal\Controller;
use Doctrine\ORM\Mapping as ORM;
/*                                                                        *
 * This script belongs to the FLOW3 package "Ccc.Gal".                    *
 *                                                                        *
 *                                                                        */

use TYPO3\FLOW3\Annotations as FLOW3;

/**
 * gallery controller for the Ccc.Gal package 
 *
 * @FLOW3\Scope("singleton")
 */
class GalleryController extends \TYPO3\FLOW3\Mvc\Controller\ActionController {

	/**
	* @FLOW3\Inject
	* @var \Ccc\Gal\Domain\Repository\GalleryRepository
	*/
	protected $galleryRepository;

	/**
	 * Index action
	 *
	 * @return void
	 */
	public function indexAction() {
		$this->view->assign('galleries', $this->galleryRepository->findAll());
	}
	
	/**
	 * Displays a form for creating a new gallery
	 *
	 * @return void
	 */
	public function newAction() {

	}
	
	/**
	 * Edit action displays a form for editing 
	 * @param \Ccc\Gal\Domain\Model\Gallery $gallery
	 * @FLOW3\IgnoreValidation("$gallery")
	 * @return void
	 */
	public function editAction(\Ccc\Gal\Domain\Model\Gallery $gallery) {
		$this->view->assign('gallery', $gallery);
	}
	
	/**
	 * Update action updates gallerydata 
     * @param \Ccc\Gal\Domain\Model\Gallery $gallery 
	 * @FLOW3\IgnoreValidation("$gallery")
	 * @return void
	 */
	public function updateAction(\Ccc\Gal\Domain\Model\Gallery $gallery) {
		$this->galleryRepository->update($gallery);
		$this->redirect('index');
	}
	
	/**
	 * Create action
	 * @param \Ccc\Gal\Domain\Model\Gallery $newGallery
	 * @return void
	 */
	public function createAction(\Ccc\Gal\Domain\Model\Gallery $newGallery) {
		$this->galleryRepository->add($newGallery);	
	}
		
	/**
	 * Ajaxnew action
	 * @return void
	 */
	public function ajaxnewAction() {
		
	}	
	
	/**
	 * Ajaxcreate action
	 * @param \Ccc\Gal\Domain\Model\Gallery $newGallery
	 * @return string
	 */
	public function ajaxcreateAction(\Ccc\Gal\Domain\Model\Gallery $newGallery) {
		$this->galleryRepository->add($newGallery);	
		return $this->newGallery;
	}
	
	/**
	 * Ajaxedit action displays a form for editing 
	 * @param \Ccc\Gal\Domain\Model\Gallery $gallery
	 * @FLOW3\IgnoreValidation("$gallery")
	 * @return void
	 */
	public function ajaxeditAction(\Ccc\Gal\Domain\Model\Gallery $gallery) {
		$this->view->assign('gallery', $gallery);
	}	
	
	/**
	 * Ajaxupdate action
	 * @param \Ccc\Gal\Domain\Model\Gallery $gallery
	 * @FLOW3\IgnoreValidation("$gallery")
	 * @return void
	 */
	public function ajaxupdateAction(\Ccc\Gal\Domain\Model\Gallery $gallery) {
		$this->galleryRepository->update($gallery);	
	}	
		
}

?>